package io.renren.modules.health.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.health.dao.FoodPrePlanDao;
import io.renren.modules.health.dto.FoodPrePlanDTO;
import io.renren.modules.health.entity.FoodPrePlanEntity;
import io.renren.modules.health.service.FoodPrePlanService;
import cn.hutool.core.util.StrUtil;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 饮食方案
 *
 * @author Mark 
 * @since 1.0.0 2024-04-01
 */
@Service
public class FoodPrePlanServiceImpl extends CrudServiceImpl<FoodPrePlanDao, FoodPrePlanEntity, FoodPrePlanDTO> implements FoodPrePlanService {

    @Override
    public QueryWrapper<FoodPrePlanEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");
        Double bmi = (Double) params.get("bmi");

        QueryWrapper<FoodPrePlanEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);
        wrapper.lt(bmi != null, "start_bmi", bmi).gt(bmi != null, "end_bmi", bmi);

        return wrapper;
    }


}